﻿#region Using Directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;

using NetROS.Tiers.Entities;
using NetROS.Tiers.Data;
using NetROS.Tiers.Data.Bases;
using NetROS.Tiers.Services;
#endregion

namespace NetROS.Tiers.Web.Data
{
	/// <summary>
	/// Represents the DataRepository.KnjizenjeStavkaProvider object that provides
	/// data to data-bound controls in multi-tier Web application architectures.
	/// </summary>
	[Designer(typeof(KnjizenjeStavkaDataSourceDesigner))]
	public class KnjizenjeStavkaDataSource : ProviderDataSource<KnjizenjeStavka, KnjizenjeStavkaKey>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the KnjizenjeStavkaDataSource class.
		/// </summary>
		public KnjizenjeStavkaDataSource() : base(new KnjizenjeStavkaService())
		{
		}

		#endregion Constructors
		
		#region Properties
		
		/// <summary>
		/// Gets a reference to the KnjizenjeStavkaDataSourceView used by the KnjizenjeStavkaDataSource.
		/// </summary>
		protected KnjizenjeStavkaDataSourceView KnjizenjeStavkaView
		{
			get { return ( View as KnjizenjeStavkaDataSourceView ); }
		}
		
		/// <summary>
		/// Gets or sets the name of the method or function that
		/// the KnjizenjeStavkaDataSource control invokes to retrieve data.
		/// </summary>
		public KnjizenjeStavkaSelectMethod SelectMethod
		{
			get
			{
				KnjizenjeStavkaSelectMethod selectMethod = KnjizenjeStavkaSelectMethod.GetAll;
				Object method = ViewState["SelectMethod"];
				if ( method != null )
				{
					selectMethod = (KnjizenjeStavkaSelectMethod) method;
				}
				return selectMethod;
			}
			set { ViewState["SelectMethod"] = value; }
		}

		#endregion Properties
		
		#region Methods

		/// <summary>
		/// Creates a new instance of the KnjizenjeStavkaDataSourceView class that is to be
		/// used by the KnjizenjeStavkaDataSource.
		/// </summary>
		/// <returns>An instance of the KnjizenjeStavkaDataSourceView class.</returns>
		protected override BaseDataSourceView<KnjizenjeStavka, KnjizenjeStavkaKey> GetNewDataSourceView()
		{
			return new KnjizenjeStavkaDataSourceView(this, DefaultViewName);
		}
		
		/// <summary>
        /// Creates a cache hashing key based on the startIndex, pageSize and the SelectMethod being used.
        /// </summary>
        /// <param name="startIndex">The current start row index.</param>
        /// <param name="pageSize">The current page size.</param>
        /// <returns>A string that can be used as a key for caching purposes.</returns>
		protected override string CacheHashKey(int startIndex, int pageSize)
        {
			return String.Format("{0}:{1}:{2}", SelectMethod, startIndex, pageSize);
        }
		
		#endregion Methods
	}
	
	/// <summary>
	/// Supports the KnjizenjeStavkaDataSource control and provides an interface for
	/// data-bound controls to perform data operations with business and data objects.
	/// </summary>
	public class KnjizenjeStavkaDataSourceView : ProviderDataSourceView<KnjizenjeStavka, KnjizenjeStavkaKey>
	{
		#region Declarations

		#endregion Declarations
		
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the KnjizenjeStavkaDataSourceView class.
		/// </summary>
		/// <param name="owner">A reference to the KnjizenjeStavkaDataSource which created this instance.</param>
		/// <param name="viewName">The name of the view.</param>
		public KnjizenjeStavkaDataSourceView(KnjizenjeStavkaDataSource owner, String viewName)
			: base(owner, viewName)
		{
		}
		
		#endregion Constructors
		
		#region Properties

		/// <summary>
		/// Gets a strongly-typed reference to the Owner property.
		/// </summary>
		internal KnjizenjeStavkaDataSource KnjizenjeStavkaOwner
		{
			get { return Owner as KnjizenjeStavkaDataSource; }
		}

		/// <summary>
		/// Gets or sets the name of the method or function that
		/// the DataSource control invokes to retrieve data.
		/// </summary>
		internal KnjizenjeStavkaSelectMethod SelectMethod
		{
			get { return KnjizenjeStavkaOwner.SelectMethod; }
			set { KnjizenjeStavkaOwner.SelectMethod = value; }
		}

		/// <summary>
		/// Gets a strongly typed reference to the Provider property.
		/// </summary>
		internal KnjizenjeStavkaService KnjizenjeStavkaProvider
		{
			get { return Provider as KnjizenjeStavkaService; }
		}

		#endregion Properties
		
		#region Methods
		
		/// <summary>
		/// Gets a collection of Entity objects based on the value of the SelectMethod property.
		/// </summary>
		/// <param name="count">The total number of rows in the DataSource.</param>
		/// <returns>A collection of Entity objects.</returns>
		protected override IList<KnjizenjeStavka> GetSelectData(out int count)
		{
			Hashtable values = CollectionsUtil.CreateCaseInsensitiveHashtable(GetParameterValues());
			Hashtable customOutput = CollectionsUtil.CreateCaseInsensitiveHashtable();
			IList<KnjizenjeStavka> results = null;
			KnjizenjeStavka item;
			count = 0;
			
			System.Int32 iD;
			System.DateTime datumDokumentaOriginal;
			System.String opisKnjizenja_nullable;
			System.Decimal dug;
			System.Decimal pot;
			System.String placanjeModel_nullable;
			System.String placanjePoziv_nullable;
			System.Int32? iDKlijent_nullable;
			System.Int32 iDKonto;
			System.Int32 iDKnjizenja;
			System.Int32 iDOrganizacija;
			System.Int32 prikazUKnjizi;
			System.String sifraOriginalnogDokumenta_nullable;
			System.String kontoSifraPrijenos_nullable;
			System.Int32? iDDokument_nullable;
			System.String calculated_nullable;
			System.Int32 iDVrstaFinDokumenta;
			System.Int32 iDUserCreated;
			System.Int32 iDUserModified;
			System.Int32? sp57_IDKnjizenjeStavka;
			System.Boolean? sp57_PoVrijednostiPrviDatum;
			System.String sp52_Filter;
			System.DateTime? sp52_DatumDokOd;
			System.DateTime? sp52_DatumDokDo;
			System.DateTime? sp52_DatumDokDosOd;
			System.DateTime? sp52_DatumDokDosDo;
			System.String sp54_Filter;
			System.DateTime? sp54_DatumDokOd;
			System.DateTime? sp54_DatumDokDo;
			System.DateTime? sp54_DatumDokDosOd;
			System.DateTime? sp54_DatumDokDosDo;

			switch ( SelectMethod )
			{
				case KnjizenjeStavkaSelectMethod.Get:
					KnjizenjeStavkaKey entityKey  = new KnjizenjeStavkaKey();
					entityKey.Load(values);
					item = KnjizenjeStavkaProvider.Get(entityKey);
					results = new TList<KnjizenjeStavka>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case KnjizenjeStavkaSelectMethod.GetAll:
                    results = KnjizenjeStavkaProvider.GetAll(StartIndex, PageSize, out count);
                    break;
				case KnjizenjeStavkaSelectMethod.GetPaged:
					results = KnjizenjeStavkaProvider.GetPaged(WhereClause, OrderBy, PageIndex, PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.Find:
					if ( FilterParameters != null )
						results = KnjizenjeStavkaProvider.Find(FilterParameters, OrderBy, StartIndex, PageSize, out count);
					else
						results = KnjizenjeStavkaProvider.Find(WhereClause, StartIndex, PageSize, out count);
                    break;
				// PK
				case KnjizenjeStavkaSelectMethod.GetByID:
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					item = KnjizenjeStavkaProvider.GetByID(iD);
					results = new TList<KnjizenjeStavka>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				// IX
				case KnjizenjeStavkaSelectMethod.GetByIDDatumDokumentaOriginalOpisKnjizenjaDugPotPlacanjeModelPlacanjePozivIDKlijent:
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					datumDokumentaOriginal = ( values["DatumDokumentaOriginal"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["DatumDokumentaOriginal"], typeof(System.DateTime)) : DateTime.Now;
					opisKnjizenja_nullable = (System.String) EntityUtil.ChangeType(values["OpisKnjizenja"], typeof(System.String));
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					placanjeModel_nullable = (System.String) EntityUtil.ChangeType(values["PlacanjeModel"], typeof(System.String));
					placanjePoziv_nullable = (System.String) EntityUtil.ChangeType(values["PlacanjePoziv"], typeof(System.String));
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					results = KnjizenjeStavkaProvider.GetByIDDatumDokumentaOriginalOpisKnjizenjaDugPotPlacanjeModelPlacanjePozivIDKlijent(iD, datumDokumentaOriginal, opisKnjizenja_nullable, dug, pot, placanjeModel_nullable, placanjePoziv_nullable, iDKlijent_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKlijentIDPotDug:
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					results = KnjizenjeStavkaProvider.GetByIDKlijentIDPotDug(iDKlijent_nullable, iD, pot, dug, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKontoIDIDKlijentIDKnjizenjaIDOrganizacijaPotDugPrikazUKnjiziSifraOriginalnogDokumenta:
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					iDKnjizenja = ( values["IDKnjizenja"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKnjizenja"], typeof(System.Int32)) : (int)0;
					iDOrganizacija = ( values["IDOrganizacija"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDOrganizacija"], typeof(System.Int32)) : (int)0;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					prikazUKnjizi = ( values["PrikazUKnjizi"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["PrikazUKnjizi"], typeof(System.Int32)) : (int)1;
					sifraOriginalnogDokumenta_nullable = (System.String) EntityUtil.ChangeType(values["SifraOriginalnogDokumenta"], typeof(System.String));
					results = KnjizenjeStavkaProvider.GetByIDKontoIDIDKlijentIDKnjizenjaIDOrganizacijaPotDugPrikazUKnjiziSifraOriginalnogDokumenta(iDKonto, iD, iDKlijent_nullable, iDKnjizenja, iDOrganizacija, pot, dug, prikazUKnjizi, sifraOriginalnogDokumenta_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKontoIDKlijentIDOrganizacija:
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					iDOrganizacija = ( values["IDOrganizacija"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDOrganizacija"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByIDKontoIDKlijentIDOrganizacija(iDKonto, iDKlijent_nullable, iDOrganizacija, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByPrikazUKnjiziIDKlijentIDKnjizenjaIDOrganizacijaIDKontoPotDugSifraOriginalnogDokumenta:
					prikazUKnjizi = ( values["PrikazUKnjizi"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["PrikazUKnjizi"], typeof(System.Int32)) : (int)1;
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					iDKnjizenja = ( values["IDKnjizenja"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKnjizenja"], typeof(System.Int32)) : (int)0;
					iDOrganizacija = ( values["IDOrganizacija"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDOrganizacija"], typeof(System.Int32)) : (int)0;
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					sifraOriginalnogDokumenta_nullable = (System.String) EntityUtil.ChangeType(values["SifraOriginalnogDokumenta"], typeof(System.String));
					results = KnjizenjeStavkaProvider.GetByPrikazUKnjiziIDKlijentIDKnjizenjaIDOrganizacijaIDKontoPotDugSifraOriginalnogDokumenta(prikazUKnjizi, iDKlijent_nullable, iDKnjizenja, iDOrganizacija, iDKonto, pot, dug, sifraOriginalnogDokumenta_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKontoDugPot:
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					results = KnjizenjeStavkaProvider.GetByIDKontoDugPot(iDKonto, dug, pot, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByKontoSifraPrijenosIDDokumentCalculated:
					kontoSifraPrijenos_nullable = (System.String) EntityUtil.ChangeType(values["KontoSifraPrijenos"], typeof(System.String));
					iDDokument_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDDokument"], typeof(System.Int32?));
					calculated_nullable = (System.String) EntityUtil.ChangeType(values["Calculated"], typeof(System.String));
					item = KnjizenjeStavkaProvider.GetByKontoSifraPrijenosIDDokumentCalculated(kontoSifraPrijenos_nullable, iDDokument_nullable, calculated_nullable);
					results = new TList<KnjizenjeStavka>();
					if ( item != null ) results.Add(item);
					count = results.Count;
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKlijentIDKontoIDOrganizacijaDatumDokumentaOriginalIDVrstaFinDokumenta:
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					iDOrganizacija = ( values["IDOrganizacija"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDOrganizacija"], typeof(System.Int32)) : (int)0;
					datumDokumentaOriginal = ( values["DatumDokumentaOriginal"] != null ) ? (System.DateTime) EntityUtil.ChangeType(values["DatumDokumentaOriginal"], typeof(System.DateTime)) : DateTime.Now;
					iDVrstaFinDokumenta = ( values["IDVrstaFinDokumenta"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDVrstaFinDokumenta"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByIDKlijentIDKontoIDOrganizacijaDatumDokumentaOriginalIDVrstaFinDokumenta(iDKlijent_nullable, iDKonto, iDOrganizacija, datumDokumentaOriginal, iDVrstaFinDokumenta, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKonto:
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByIDKonto(iDKonto, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKontoDugPotIDIDKlijentIDKnjizenjaPrikazUKnjizi:
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					iDKnjizenja = ( values["IDKnjizenja"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKnjizenja"], typeof(System.Int32)) : (int)0;
					prikazUKnjizi = ( values["PrikazUKnjizi"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["PrikazUKnjizi"], typeof(System.Int32)) : (int)1;
					results = KnjizenjeStavkaProvider.GetByIDKontoDugPotIDIDKlijentIDKnjizenjaPrikazUKnjizi(iDKonto, dug, pot, iD, iDKlijent_nullable, iDKnjizenja, prikazUKnjizi, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDPotDug:
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					results = KnjizenjeStavkaProvider.GetByIDPotDug(iD, pot, dug, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDDugPot:
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					results = KnjizenjeStavkaProvider.GetByIDDugPot(iD, dug, pot, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKlijentPotDugID:
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByIDKlijentPotDugID(iDKlijent_nullable, pot, dug, iD, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKnjizenjaPotIDDugIDKlijentIDKonto:
					iDKnjizenja = ( values["IDKnjizenja"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKnjizenja"], typeof(System.Int32)) : (int)0;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByIDKnjizenjaPotIDDugIDKlijentIDKonto(iDKnjizenja, pot, iD, dug, iDKlijent_nullable, iDKonto, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKontoIDPotDug:
					iDKonto = ( values["IDKonto"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKonto"], typeof(System.Int32)) : (int)0;
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					pot = ( values["Pot"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Pot"], typeof(System.Decimal)) : 0m;
					dug = ( values["Dug"] != null ) ? (System.Decimal) EntityUtil.ChangeType(values["Dug"], typeof(System.Decimal)) : 0m;
					results = KnjizenjeStavkaProvider.GetByIDKontoIDPotDug(iDKonto, iD, pot, dug, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByPlacanjePozivPlacanjeModelID:
					placanjePoziv_nullable = (System.String) EntityUtil.ChangeType(values["PlacanjePoziv"], typeof(System.String));
					placanjeModel_nullable = (System.String) EntityUtil.ChangeType(values["PlacanjeModel"], typeof(System.String));
					iD = ( values["ID"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ID"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByPlacanjePozivPlacanjeModelID(placanjePoziv_nullable, placanjeModel_nullable, iD, this.StartIndex, this.PageSize, out count);
					break;
				// FK
				case KnjizenjeStavkaSelectMethod.GetByIDOrganizacija:
					iDOrganizacija = ( values["IDOrganizacija"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDOrganizacija"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByIDOrganizacija(iDOrganizacija, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDUserCreated:
					iDUserCreated = ( values["IDUserCreated"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDUserCreated"], typeof(System.Int32)) : (int)1;
					results = KnjizenjeStavkaProvider.GetByIDUserCreated(iDUserCreated, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDUserModified:
					iDUserModified = ( values["IDUserModified"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDUserModified"], typeof(System.Int32)) : (int)1;
					results = KnjizenjeStavkaProvider.GetByIDUserModified(iDUserModified, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDDokument:
					iDDokument_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDDokument"], typeof(System.Int32?));
					results = KnjizenjeStavkaProvider.GetByIDDokument(iDDokument_nullable, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKnjizenja:
					iDKnjizenja = ( values["IDKnjizenja"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDKnjizenja"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByIDKnjizenja(iDKnjizenja, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDVrstaFinDokumenta:
					iDVrstaFinDokumenta = ( values["IDVrstaFinDokumenta"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["IDVrstaFinDokumenta"], typeof(System.Int32)) : (int)0;
					results = KnjizenjeStavkaProvider.GetByIDVrstaFinDokumenta(iDVrstaFinDokumenta, this.StartIndex, this.PageSize, out count);
					break;
				case KnjizenjeStavkaSelectMethod.GetByIDKlijent:
					iDKlijent_nullable = (System.Int32?) EntityUtil.ChangeType(values["IDKlijent"], typeof(System.Int32?));
					results = KnjizenjeStavkaProvider.GetByIDKlijent(iDKlijent_nullable, this.StartIndex, this.PageSize, out count);
					break;
				// M:M
				// Custom
				case KnjizenjeStavkaSelectMethod.ZatvoriStavku_PoVrijed:
					sp57_IDKnjizenjeStavka = (System.Int32?) EntityUtil.ChangeType(values["@IDKnjizenjeStavka"], typeof(System.Int32?));
					sp57_PoVrijednostiPrviDatum = (System.Boolean?) EntityUtil.ChangeType(values["@PoVrijednostiPrviDatum"], typeof(System.Boolean?));
					results = KnjizenjeStavkaProvider.ZatvoriStavku_PoVrijed(sp57_IDKnjizenjeStavka, sp57_PoVrijednostiPrviDatum, StartIndex, PageSize);
					break;
				case KnjizenjeStavkaSelectMethod.TraziStavke:
					sp52_Filter = (System.String) EntityUtil.ChangeType(values["@filter"], typeof(System.String));
					sp52_DatumDokOd = (System.DateTime?) EntityUtil.ChangeType(values["@DatumDokOd"], typeof(System.DateTime?));
					sp52_DatumDokDo = (System.DateTime?) EntityUtil.ChangeType(values["@DatumDokDo"], typeof(System.DateTime?));
					sp52_DatumDokDosOd = (System.DateTime?) EntityUtil.ChangeType(values["@DatumDokDosOd"], typeof(System.DateTime?));
					sp52_DatumDokDosDo = (System.DateTime?) EntityUtil.ChangeType(values["@DatumDokDosDo"], typeof(System.DateTime?));
					results = KnjizenjeStavkaProvider.TraziStavke(sp52_Filter, sp52_DatumDokOd, sp52_DatumDokDo, sp52_DatumDokDosOd, sp52_DatumDokDosDo, StartIndex, PageSize);
					break;
				case KnjizenjeStavkaSelectMethod.TraziStavke_Otvorene:
					sp54_Filter = (System.String) EntityUtil.ChangeType(values["@filter"], typeof(System.String));
					sp54_DatumDokOd = (System.DateTime?) EntityUtil.ChangeType(values["@DatumDokOd"], typeof(System.DateTime?));
					sp54_DatumDokDo = (System.DateTime?) EntityUtil.ChangeType(values["@DatumDokDo"], typeof(System.DateTime?));
					sp54_DatumDokDosOd = (System.DateTime?) EntityUtil.ChangeType(values["@DatumDokDosOd"], typeof(System.DateTime?));
					sp54_DatumDokDosDo = (System.DateTime?) EntityUtil.ChangeType(values["@DatumDokDosDo"], typeof(System.DateTime?));
					results = KnjizenjeStavkaProvider.TraziStavke_Otvorene(sp54_Filter, sp54_DatumDokOd, sp54_DatumDokDo, sp54_DatumDokDosOd, sp54_DatumDokDosDo, StartIndex, PageSize);
					break;
				default:
					break;
			}

			if ( results != null && count < 1 )
			{
				count = results.Count;

				if ( !String.IsNullOrEmpty(CustomMethodRecordCountParamName) )
				{
					object objCustomCount = EntityUtil.ChangeType(customOutput[CustomMethodRecordCountParamName], typeof(Int32));
					
					if ( objCustomCount != null )
					{
						count = (int) objCustomCount;
					}
				}
			}
			
			return results;
		}
		
		/// <summary>
		/// Gets the values of any supplied parameters for internal caching.
		/// </summary>
		/// <param name="values">An IDictionary object of name/value pairs.</param>
		protected override void GetSelectParameters(IDictionary values)
		{
			if ( SelectMethod == KnjizenjeStavkaSelectMethod.Get || SelectMethod == KnjizenjeStavkaSelectMethod.GetByID )
			{
				EntityId = GetEntityKey(values);
			}
		}

		/// <summary>
		/// Performs a DeepLoad operation for the current entity if it has
		/// not already been performed.
		/// </summary>
		internal override void DeepLoad()
		{
			if ( !IsDeepLoaded )
			{
				KnjizenjeStavka entity = GetCurrentEntity();
				
				if ( entity != null )
				{
					// init transaction manager
					GetTransactionManager();
					// execute deep load method
					KnjizenjeStavkaProvider.DeepLoad(GetCurrentEntity(), EnableRecursiveDeepLoad);
					// set loaded flag
					IsDeepLoaded = true;
				}
			}
		}

		/// <summary>
		/// Performs a DeepLoad operation on the specified entity collection.
		/// </summary>
		/// <param name="entityList"></param>
		/// <param name="properties"></param>
		internal override void DeepLoad(TList<KnjizenjeStavka> entityList, ProviderDataSourceDeepLoadList properties)
		{
			// init transaction manager
			GetTransactionManager();
			// execute deep load method
			KnjizenjeStavkaProvider.DeepLoad(entityList, properties.Recursive, properties.Method, properties.GetTypes());
		}

		#endregion Select Methods
	}
	
	#region KnjizenjeStavkaDataSourceDesigner

	/// <summary>
	/// Provides design-time support in a design host for the KnjizenjeStavkaDataSource class.
	/// </summary>
	public class KnjizenjeStavkaDataSourceDesigner : ProviderDataSourceDesigner<KnjizenjeStavka, KnjizenjeStavkaKey>
	{
		/// <summary>
		/// Initializes a new instance of the KnjizenjeStavkaDataSourceDesigner class.
		/// </summary>
		public KnjizenjeStavkaDataSourceDesigner()
		{
		}

		/// <summary>
		/// Gets or sets the SelectMethod property.
		/// </summary>
		public KnjizenjeStavkaSelectMethod SelectMethod
		{
			get { return ((KnjizenjeStavkaDataSource) DataSource).SelectMethod; }
			set { SetPropertyValue("SelectMethod", value); }
		}

		/// <summary>Gets the designer action list collection for this designer.</summary>
		/// <returns>The <see cref="T:System.ComponentModel.Design.DesignerActionListCollection"/>
		/// associated with this designer.</returns>
		public override DesignerActionListCollection ActionLists
		{
			get
			{
				DesignerActionListCollection actions = new DesignerActionListCollection();
				actions.Add(new KnjizenjeStavkaDataSourceActionList(this));
				actions.AddRange(base.ActionLists);
				return actions;
			}
		}
	}

	#region KnjizenjeStavkaDataSourceActionList

	/// <summary>
	/// Supports the KnjizenjeStavkaDataSourceDesigner class.
	/// </summary>
	internal class KnjizenjeStavkaDataSourceActionList : DesignerActionList
	{
		private KnjizenjeStavkaDataSourceDesigner _designer;

		/// <summary>
		/// Initializes a new instance of the KnjizenjeStavkaDataSourceActionList class.
		/// </summary>
		/// <param name="designer"></param>
		public KnjizenjeStavkaDataSourceActionList(KnjizenjeStavkaDataSourceDesigner designer) : base(designer.Component)
		{
			_designer = designer;
		}

		/// <summary>
		/// Gets or sets the SelectMethod property.
		/// </summary>
		public KnjizenjeStavkaSelectMethod SelectMethod
		{
			get { return _designer.SelectMethod; }
			set { _designer.SelectMethod = value; }
		}

		/// <summary>
		/// Returns the collection of <see cref="T:System.ComponentModel.Design.DesignerActionItem"/>
		/// objects contained in the list.
		/// </summary>
		/// <returns>A <see cref="T:System.ComponentModel.Design.DesignerActionItem"/>
		/// array that contains the items in this list.</returns>
		public override DesignerActionItemCollection GetSortedActionItems()
		{
			DesignerActionItemCollection items = new DesignerActionItemCollection();
			items.Add(new DesignerActionPropertyItem("SelectMethod", "Select Method", "Methods"));
			return items;
		}
	}

	#endregion KnjizenjeStavkaDataSourceActionList
	
	#endregion KnjizenjeStavkaDataSourceDesigner
	
	#region KnjizenjeStavkaSelectMethod
	
	/// <summary>
	/// Enumeration of method names available for the KnjizenjeStavkaDataSource.SelectMethod property.
	/// </summary>
	public enum KnjizenjeStavkaSelectMethod
	{
		/// <summary>
		/// Represents the Get method.
		/// </summary>
		Get,
		/// <summary>
		/// Represents the GetAll method.
		/// </summary>
		GetAll,
		/// <summary>
		/// Represents the GetPaged method.
		/// </summary>
		GetPaged,
		/// <summary>
		/// Represents the Find method.
		/// </summary>
		Find,
		/// <summary>
		/// Represents the GetByID method.
		/// </summary>
		GetByID,
		/// <summary>
		/// Represents the GetByIDDatumDokumentaOriginalOpisKnjizenjaDugPotPlacanjeModelPlacanjePozivIDKlijent method.
		/// </summary>
		GetByIDDatumDokumentaOriginalOpisKnjizenjaDugPotPlacanjeModelPlacanjePozivIDKlijent,
		/// <summary>
		/// Represents the GetByIDKlijentIDPotDug method.
		/// </summary>
		GetByIDKlijentIDPotDug,
		/// <summary>
		/// Represents the GetByIDKontoIDIDKlijentIDKnjizenjaIDOrganizacijaPotDugPrikazUKnjiziSifraOriginalnogDokumenta method.
		/// </summary>
		GetByIDKontoIDIDKlijentIDKnjizenjaIDOrganizacijaPotDugPrikazUKnjiziSifraOriginalnogDokumenta,
		/// <summary>
		/// Represents the GetByIDKontoIDKlijentIDOrganizacija method.
		/// </summary>
		GetByIDKontoIDKlijentIDOrganizacija,
		/// <summary>
		/// Represents the GetByPrikazUKnjiziIDKlijentIDKnjizenjaIDOrganizacijaIDKontoPotDugSifraOriginalnogDokumenta method.
		/// </summary>
		GetByPrikazUKnjiziIDKlijentIDKnjizenjaIDOrganizacijaIDKontoPotDugSifraOriginalnogDokumenta,
		/// <summary>
		/// Represents the GetByIDKontoDugPot method.
		/// </summary>
		GetByIDKontoDugPot,
		/// <summary>
		/// Represents the GetByKontoSifraPrijenosIDDokumentCalculated method.
		/// </summary>
		GetByKontoSifraPrijenosIDDokumentCalculated,
		/// <summary>
		/// Represents the GetByIDKlijentIDKontoIDOrganizacijaDatumDokumentaOriginalIDVrstaFinDokumenta method.
		/// </summary>
		GetByIDKlijentIDKontoIDOrganizacijaDatumDokumentaOriginalIDVrstaFinDokumenta,
		/// <summary>
		/// Represents the GetByIDKonto method.
		/// </summary>
		GetByIDKonto,
		/// <summary>
		/// Represents the GetByIDKontoDugPotIDIDKlijentIDKnjizenjaPrikazUKnjizi method.
		/// </summary>
		GetByIDKontoDugPotIDIDKlijentIDKnjizenjaPrikazUKnjizi,
		/// <summary>
		/// Represents the GetByIDPotDug method.
		/// </summary>
		GetByIDPotDug,
		/// <summary>
		/// Represents the GetByIDDugPot method.
		/// </summary>
		GetByIDDugPot,
		/// <summary>
		/// Represents the GetByIDKlijentPotDugID method.
		/// </summary>
		GetByIDKlijentPotDugID,
		/// <summary>
		/// Represents the GetByIDKnjizenjaPotIDDugIDKlijentIDKonto method.
		/// </summary>
		GetByIDKnjizenjaPotIDDugIDKlijentIDKonto,
		/// <summary>
		/// Represents the GetByIDKontoIDPotDug method.
		/// </summary>
		GetByIDKontoIDPotDug,
		/// <summary>
		/// Represents the GetByPlacanjePozivPlacanjeModelID method.
		/// </summary>
		GetByPlacanjePozivPlacanjeModelID,
		/// <summary>
		/// Represents the GetByIDOrganizacija method.
		/// </summary>
		GetByIDOrganizacija,
		/// <summary>
		/// Represents the GetByIDUserCreated method.
		/// </summary>
		GetByIDUserCreated,
		/// <summary>
		/// Represents the GetByIDUserModified method.
		/// </summary>
		GetByIDUserModified,
		/// <summary>
		/// Represents the GetByIDDokument method.
		/// </summary>
		GetByIDDokument,
		/// <summary>
		/// Represents the GetByIDKnjizenja method.
		/// </summary>
		GetByIDKnjizenja,
		/// <summary>
		/// Represents the GetByIDVrstaFinDokumenta method.
		/// </summary>
		GetByIDVrstaFinDokumenta,
		/// <summary>
		/// Represents the GetByIDKlijent method.
		/// </summary>
		GetByIDKlijent,
		/// <summary>
		/// Represents the ZatvoriStavku_PoVrijed method.
		/// </summary>
		ZatvoriStavku_PoVrijed,
		/// <summary>
		/// Represents the TraziStavke method.
		/// </summary>
		TraziStavke,
		/// <summary>
		/// Represents the TraziStavke_Otvorene method.
		/// </summary>
		TraziStavke_Otvorene
	}
	
	#endregion KnjizenjeStavkaSelectMethod

	#region KnjizenjeStavkaFilter
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilter&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="KnjizenjeStavka"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class KnjizenjeStavkaFilter : SqlFilter<KnjizenjeStavkaColumn>
	{
	}
	
	#endregion KnjizenjeStavkaFilter

	#region KnjizenjeStavkaExpressionBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlExpressionBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="KnjizenjeStavka"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class KnjizenjeStavkaExpressionBuilder : SqlExpressionBuilder<KnjizenjeStavkaColumn>
	{
	}
	
	#endregion KnjizenjeStavkaExpressionBuilder	

	#region KnjizenjeStavkaProperty
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ChildEntityProperty&lt;KnjizenjeStavkaChildEntityTypes&gt;"/> class
	/// that is used exclusively with a <see cref="KnjizenjeStavka"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class KnjizenjeStavkaProperty : ChildEntityProperty<KnjizenjeStavkaChildEntityTypes>
	{
	}
	
	#endregion KnjizenjeStavkaProperty
}

